package com.lphl.pet.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;
import com.jeremyfeinstein.slidingmenu.lib.app.SlidingFragmentActivity;
import com.lphl.pet.R;
import com.lphl.pet.RoundProgressBar;
import com.lphl.pet.fragment.MenuFragment;
import com.lphl.pet.util.PopWindowUtils;

public class FirstActivity extends SlidingFragmentActivity implements OnClickListener{

    private TextView tv_setting;
    private TextView tv_humor_num;
    private RoundProgressBar roundProgressBar;
    private ImageView iv_pet;
    private TextView tv_share_friend;
    private TextView suporttime;
    private TextView resttime;
    private TextView vigorous;
    private TextView power;
    private LinearLayout ll_analysis;
    private LinearLayout ll_noopsyche;
    private LinearLayout ll_pet_location;
    private LinearLayout ll_sight;
    private LinearLayout ll_down_icon;
    private SlidingMenu slidingMenu;
    private ImageView iv_down_icon;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_first);

        // 侧拉菜单布局
        setBehindContentView(R.layout.menu_frame);
        slidingMenu = getSlidingMenu();
        slidingMenu.setMode(SlidingMenu.RIGHT);
        slidingMenu.setAboveOffset(SlidingMenu.RIGHT); // 设置侧拉栏目位置
        slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); // 拖拽边缘有效
        slidingMenu.setBehindOffsetRes(R.dimen.slidingmenu_offset); // 设置内容页大小
        slidingMenu.setShadowDrawable(R.drawable.shadow); // 给侧拉栏目与内容页区分
        slidingMenu.setShadowWidthRes(R.dimen.shadow_width); // 设置线宽度

        MenuFragment menuFragment = new MenuFragment();
        getSupportFragmentManager()
                .beginTransaction()
                .replace(R.id.menu, menuFragment, "MENU")
                .commit();
        initView();
    }

    private void initView() {
        ll_down_icon = (LinearLayout) findViewById(R.id.ll_down_icon);
        iv_down_icon = (ImageView) findViewById(R.id.iv_down_icon);
        tv_setting = (TextView) findViewById(R.id.tv_setting);
        tv_humor_num = (TextView) findViewById(R.id.tv_humor_num);
        roundProgressBar = (RoundProgressBar) findViewById(R.id.roundProgressBar);
        roundProgressBar.setProgress(80);
        iv_pet = (ImageView) findViewById(R.id.iv_pet_icon);
        tv_share_friend = (TextView) findViewById(R.id.tv_share_friend);
        suporttime = (TextView) findViewById(R.id.suporttime);
        resttime = (TextView) findViewById(R.id.resttime);
        vigorous = (TextView) findViewById(R.id.vigorous);
        power = (TextView) findViewById(R.id.power);

        ll_analysis = (LinearLayout) findViewById(R.id.ll_analysis);
        ll_noopsyche = (LinearLayout) findViewById(R.id.ll_noopsyche);
        ll_pet_location = (LinearLayout) findViewById(R.id.ll_pet_location);
        ll_sight = (LinearLayout) findViewById(R.id.ll_sight);

        iv_down_icon.setOnClickListener(this);
        tv_setting.setOnClickListener(this);
        iv_pet.setOnClickListener(this);
        tv_share_friend.setOnClickListener(this);

        ll_analysis.setOnClickListener(this);
        ll_noopsyche.setOnClickListener(this);
        ll_pet_location.setOnClickListener(this);
        ll_sight.setOnClickListener(this);

    }

    @Override
    public void onClick(View v) {
        Intent intent;
        switch (v.getId()) {
            case R.id.iv_down_icon:
                PopWindowUtils pop = new PopWindowUtils(FirstActivity.this, ll_down_icon);
                pop.showWindow();
                break;

            case R.id.tv_setting:
                //拖拽导航栏
                slidingMenu.toggle();
                break;

            case R.id.iv_pet_icon:

                break;
            case R.id.tv_share_friend: // 分享好友

                break;
            case R.id.ll_analysis: // 活动分析
                intent = new Intent(FirstActivity.this, PetAnalyzeActivity.class);
                startActivity(intent);
                break;
            case R.id.ll_noopsyche: // 智能防丢

                break;
            case R.id.ll_pet_location: // 宠物位置
                intent = new Intent(FirstActivity.this, BaiduMapActivity.class);
                startActivity(intent);
                break;
            case R.id.ll_sight: // TA的视界
                intent = new Intent(FirstActivity.this, PetSightActivity.class);
                startActivity(intent);
                break;
            default:
                break;
        }
    }
}